home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
United Public Domain Gold 2
/
United Public Domain Gold 2.iso
/
utilities
/
pu181.dms
/
pu181.adf
/
Render.doc
< prev
next >
Wrap
Text File
|
1992-03-22
|
10KB
|
249 lines
\\\\\\\\|////////
Render V1.0
////////|\\\\\\\\
James Shaw April 1992
Distribution
~~~~~~~~~~~~
This program may be freely distributed. No charge whatsoever may be made
for this distribution other than a reasonable cost for its duplication. I
consider this to be less than £3. I have placed it in the Public Domain
because I am not allowed to make any profit from it as the original
program came directly from a book. If you feel you must make some donation
for its use, buy the book, or send something to charity.
Disclaimer
~~~~~~~~~~
This program is provided as is, and no responsibility for its suitability
for any task is taken by the programmer or the distributer of this software.
Introduction
~~~~~~~~~~~~
This program is a 3D graphics shading program. It implements two different
methods of getting a realistic 3D look mapped onto a surface constructed of
a set of polygons. It is not a ray-trace program (ie. there are no shadows
or reflections and the like), but some very impressive pictures can be
produced very simply.
History
~~~~~~~
This program was converted from a project set to 3rd Year Software
Engineering Graphics students at Sheffield University term 1 1992.
The original Stonybrook Modula2 source code was taken from 5Mb Viglen 386sx
PC AT's with 256 colour Super VGA graphics cards.
The original pseudo-code was taken from the book Fundamentals of Three-
Dimensional Computer Graphics by Alan H. Watt from Sheffield University,
published in 1989 by Addison-Wesley ISBN 0201154420.
Matthew Barker converted the raw source to work with Benchmark Modula2 and
since then I have converted the graphics and input/output to work with the
Amiga's Intuition library, and added the dithering routine.
Instructions
~~~~~~~~~~~~
From Workbench:
Double Click on the Render icon to run the program.
From CLI:
Set the stack size to somewhere around 100K by typing -
Stack 100000
then run the program in the normal way
ie. Render or Run Render
It is important to set the stack size to something quite large because
Benchmark code uses the CLI/Workbench stack to store the data for objects.
The stack size is automatically set when run from workbench.
To change the stacksize from workbench you must change the value in the
stacksize gadget in the Render.info icon's info screen.
When the program loads a window will open on the workbench screen.
A number of options are available.
O - Load Object
~~~~~~~~~~~~~~~
Type the name of the object to be loaded. If the object exists
in the :Render/Objects drawer then it will be loaded.
Objects can ONLY be loaded from this drawer.
When objects are loaded the currently loaded objects remain in the
memory. ie. To remove objects from the scene you will need to quit and
restart the program, though you could conceivably scale the current
objects to 0 x 0 x 0 in size! Once loaded the program will ask you if
you want to transform the object in any way. See next section for
details.
There are currently ten objects on this disk :-
Cube - A cube(!), Cyl - A cylinder. Sphere - A sphere(!),
Teapot - A teapot(!), Torus - A torus(!),
TBase, TBody, THandle, TLid, TSpout - The elements that are combined
to make the Teapot object.
Some objects will need to be scaled before they can be viewed, ie.
the teapot should be scaled by 0.5 on all axes before going, or else
the computer may guru! (Have you ever tried blitting a line directly
through a program and then asking it to run?! - Come on Commodore,
let's have an MMU next time round!)
T - Transform
~~~~~~~~~~~~~
Select the number of the object to be transformed. You will then be
asked to select whether you want to perform a displacement, rotation,
scaling or no translation to the selected object.
i) Displacement
~~~~~~~~~~~~
You will be asked to provide x, y & z displacements for the
object. These displacements are screen co-ordinate values.
ii) Rotation
~~~~~~~~
You will be asked to provide x, y & z rotations for the
object. These rotations are in degrees.
iii) Scaling
~~~~~~~
You will be asked to provide x, y & z scale factors for the
object. These scalings are relative to the current size of
the object.
W - Wireframe
~~~~~~~~~~~~~
This gives a wireframe representation of the scene which is to be
rendered. You will be asked if you would like to view the vertex
normals. If you select 'y' then small red lines will be drawn on
the wireframe indicating the direction of the normal to the polygon.
G - Gouraud
~~~~~~~~~~~
Displays the image shaded using the Gouraud shading algorithm.
P - Phong
~~~~~~~~~
Displays the image shaded using the Phong shading algorithm.
NB. There is a bug in this algorithm which does not take into
account the direction of the light source.
B - Both
~~~~~~~~
Displays both shading methods on screen at the same time.
You must first scale all objects so that they will still fit on
the screen.
M - Move Viewpoint
~~~~~~~~~~~~~~~~~~
Changes the direction that the object is looked at from.
You will be asked to enter values for Rho, Theta & Phi and Distance.
The former three values are the viewing angle and the latter is how
far away the object is to be viewed from.
L - Move Lightsource
~~~~~~~~~~~~~~~~~~~~
Changes the position of the lightsource.
You will be asked to enter values for x, y & z. These are the global
coordinates of the lightsources new position.
E - Exit
~~~~~~~~
Frees up system memory and quits the program.
Implementation
~~~~~~~~~~~~~~
Currently the program renders into a Low-Res 640 x 512 32 colour screen.
The reason for this is because the image is rendered in the left (visible)
half of the screen, and the right (hidden) half contains the z-buffer for
the image. This z-buffer is a graphical representation of how far away
specific polygons are in the image at the current time. For any polygon to
be rendered it must be in front of any which have already been drawn. On
the PC version the z-buffer is visible, but due to the fact the Amiga can
only handle 32 colours on a low-res screen and that the images were very
poor when they contained only 16 colours it seemed like this was the best
compromise for the screen resolution. It does mean, though, that all
objects must be scaled to suit the screen aspect and that when objects are
rotated they will look a bit odd.
The images are currently rendered using 64 colours, and then this value is
converted into a dithering of 32 colours for the actual image. This gives
lovely results!
There is a problem with the program in that it does not appear to free up
all the memory it has used once it has been exited. I will try to fix it
for the next release.
When the image is rendering, avoid clicking on the image screen, as this
will deselect the workbench Render window. This window needs to remain
selected while the image is rendering because only a keypress directed into
this window will get back to the menu and clear the image screen.
I very much doubt if this program will run with less than 1Mb of memory.
There is currently no save screen option in this program. As a stop gap I
have included a shareware program called ClipIt! by Mike Scalora. Read the
instructions included in the ClipIt directory on how to operate this program.
If you use it please send Mike his shareware contribution.
If you want to know the method of operation of any of the algorithms in this
program, I suggest you get a hold of Alan Watt's book mentioned in the
introduction.
Objects
~~~~~~~
There are a number of objects already stored on the disk. As there is no
object creator, here is the file structure of the objects so you can create
your own.
No. of vertices in object (N)
1 x1 y1 z1 { All values
2 x2 y2 z2 xn yn zn are reals }
3 x3 y3 z3
...
N xN yN zN
No. of sub-objects in main object (M) { All values
No. of polygons in object 1 (P) vn are integers }
No. of vertices in polygon 1 (Q) v1 v2 v3 ... vQ
No. of vertices in polygon 2 (Q) v1 v2 v3 ... vQ
No. of vertices in polygon 3 (Q) v1 v2 v3 ... vQ
...
No. of vertices in polygon P (Q) v1 v2 v3 ... vQ
No. of polygons in object 2 (P)
No. of vertices in polygon 1 (Q) v1 v2 v3 ... vQ
No. of vertices in polygon 2 (Q) v1 v2 v3 ... vQ
No. of vertices in polygon 3 (Q) v1 v2 v3 ... vQ
...
No. of vertices in polygon P (Q) v1 v2 v3 ... vQ
...
No. of polygons in object M (P)
No. of vertices in polygon 1 (Q) v1 v2 v3 ... vQ
No. of vertices in polygon 2 (Q) v1 v2 v3 ... vQ
No. of vertices in polygon 3 (Q) v1 v2 v3 ... vQ
...
No. of vertices in polygon P (Q) v1 v2 v3 ... vQ
The structure of the objects is clearly visible by loading the supplied
objects into a text editor and having a wee peek!
Future Expansion
~~~~~~~~~~~~~~~~
User definable screen options.
User definable colours.
Better interface (gadgets or menus, haven't decided yet!).
Requester for objects.
Fix Phong Shading.
Render into a pseudo 24-bit screen and convert to HAM image. (I may write
this as a supplementary program in AMOS)
Include the PC source to implement Wood and Marble effects.
Screen Save/Print option.
Better way of clearing up memory when program quits
Contact
~~~~~~~
If you want the source code for this then contact me at the following
address. Please send a blank disk. I am also open for swapping PD, hints,
tips, source for any other programs etc.
James Shaw
3 Ayr Street
Moniaive
Dumfriesshire
DG3 4HW
You could also try e-mail'ing me on
ac2s20 @ uk.ac.sheffield.primee
but I don't think i'll be there much longer!
Ta Ta!